home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / fadecode / fadedemo.c < prev    next >
C/C++ Source or Header  |  1994-08-19  |  2KB  |  103 lines

  1. #include "alloc.h"
  2. #include "io.h"
  3. #include "fcntl.h"
  4. #include "conio.h"
  5. #include "sys/stat.h"
  6.  
  7. #include "fade.h"
  8.  
  9. char pal[768];
  10. char pal2[768];
  11.  
  12.  
  13.  
  14. const char *image="satelite.raw";
  15. const char *palf1="pal1.pal";
  16. const char *palf2="pal2.pal";
  17.  
  18. int readstuff(const char *filename,void far *buf,unsigned length)
  19. {
  20.    int handle, bytes;
  21.  
  22.  
  23.    if ((handle =
  24.       sopen(filename, O_RDONLY | O_BINARY, S_IWRITE | S_IREAD)) == -1)
  25.    {
  26.       printf("Error Opening File\n");
  27.       exit(1);
  28.    }
  29.  
  30.    if ((bytes = read(handle, buf, length)) == -1) {
  31.       printf("Read Failed.\n");
  32.       exit(1);
  33.    }
  34.    return 0;
  35. }
  36.  
  37.  
  38.  
  39. void main()
  40. {  int n;
  41.    asm{           /* set mode 13h video mode*/
  42.      mov  ax,13h
  43.      int  10h
  44.    }
  45.  
  46.   /* read 320*200 raw image to video buffer*/
  47.  
  48.    fill_pal(&pal,0,0,0);  /* fill pal[768] with 0*/
  49.    setPal(&pal);
  50.    readstuff(image,(void far *)0xa0000000,64000);
  51.  
  52.   /*read palette file */
  53.    readstuff(palf1,&pal,768);
  54.    readstuff(palf2,&pal2,768);
  55.  
  56.   /* note: fade_between_screen, fade_screen, bright_screen all
  57.      change the content of the palette array */
  58.    gotoxy(1,22);
  59.    printf("fade_in         ");
  60.    fade_in_screen(&pal);
  61.    getch();
  62.  
  63.    gotoxy(1,22);
  64.    printf("palette morphing");
  65.    fade_between_screen(&pal,&pal2);
  66.    getch();
  67.  
  68.    gotoxy(1,22);
  69.    printf("brightedn out   ");
  70.    bright_out_screen(&pal);
  71.  
  72.    getch();
  73.  
  74.    readstuff(palf1,&pal,768); /* let's load the palette data again*/
  75.    gotoxy(1,22);
  76.    printf("bright in       ");
  77.    bright_in_screen(&pal);
  78.    getch();
  79.  
  80.    gotoxy(1,22);
  81.    printf("palette rotation");
  82.    n=0;
  83.    do
  84.    {rotate_pal(&pal,128+16,16,n);
  85.     if(n==15)
  86.      n=0;
  87.     else
  88.      ++n;
  89.    }while(!kbhit());
  90.  
  91.    getch();
  92.  
  93.    gotoxy(1,22);
  94.    printf("fade out        ");
  95.    fade_out_screen(&pal);
  96.  
  97.  
  98.    asm{         /* return to text mode */
  99.      mov ax,3h
  100.      int 10h
  101.    }
  102.    printf("fadedemo.exe written by Esak 1994");
  103. }